<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title> New Document </title>

  <style type="text/css">
  </style>
  <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/ext/resources/css/ext-all.css"></link>
  <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/ext/resources/css/xtheme-slate.css"></link>
  <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/public.css"></link>
		<script src="<%=request.getContextPath()%>/ext/adapter/ext/ext-base.js"></script>
		<script src="<%=request.getContextPath()%>/ext/ext-all.js"></script>
		<script src="<%=request.getContextPath()%>/ext/src/locale/ext-lang-zh_CN.js"></script>		
		<script src="<%=request.getContextPath()%>/js/md5.js"></script>	
  		
  <script>
	 Ext.BLANK_IMAGE_URL = '<%=request.getContextPath()%>/pic/blank.gif';

  var login = function() {
  	Ext.QuickTips.init();
  //	Ext.lib.Ajax.defaultPostHeader += ";charset=utf-8";
  //	Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
   
  	// 实现具体的功能
  	var form = new Ext.FormPanel( {
  		defaultType : 'textfield',
  		labelWidth : 60,
  		style : 'background:#ffffff;padding:25px 35px 30px 16px;',
  		region : 'center',
  		defaults : {
  			border : false,
  			allowBlank : false,
  			msgTarget : 'side',
  			blankText : '该字段不允许为空'
  		},
  		waitMsgTarget : true,
  		items : [
  				{
  					fieldLabel : '登录帐号',
  					name : 'userAccount',
  					//regex:/^[0-9a-zA-Z]{2,6}$/,
  					regexText:'只能为两到六位的大小写字母。'
  				},
  				{	
  					id:'userPwd',
  					fieldLabel : '登录密码',
  					name : 'userPwd',
  					inputType : 'password',
  					//regex:/^.{4,}$/,
  					regexText:'长度不能少于4位'
  				}],
  		buttons : [ {
  			text : '登陆',
  			icon : 'image/public/key.png',
  			handler : function() {
  				var pwd = encode(Ext.getCmp("userPwd").getValue());
  				var oldPwd=Ext.getCmp("userPwd").getValue();
  				Ext.getCmp('userPwd').setValue(pwd);
  				form.getForm().submit( {
  					success : function() {
  						//OpenFullWin(a.result.url);
  						
  						document.location='xdj.jsp';
  					},
  					failure:function(){
  						alert("用户名或密码错误,请从新输入");
  						Ext.getCmp('userPwd').setValue(oldPwd);
  					},
  					url : 'base/login_login',
  					waitMsg : '正在提交，请稍等...'
  				});
  			}
  		}, {
  			text : '取消',
  			handler : function() {
  				form.getForm().reset();
  			}
  		}]
   
  	});
   
  	var panel = new Ext.Panel( {
  		renderTo : 'loginpanel',
  		layout : "border",
  		width : 525,
  		height : 290,
  		defaults : {
  			border : false
  		},
  		items : [ {
  			region : "north",
  			height : 56
  		//	html : 'pic'
  		}, {
  			region : "south",
  			height : 56
  			//html : 'pic'
  		}, {
  			region : "west",
  			width : 253
  			//html : 'pic'
  		}, form]
  	});
   
  	Ext.get('loginpanel').setStyle('position', 'absolute')
  			.center(Ext.getBody());
   
  }
   
  Ext.onReady(login);

	</script>
 </head>

 <body>
 <div id='loginpanel'></div>
 </body>
</html>
